package com.example.a99544.uidemo.activity;

import android.content.Intent;
import android.content.IntentFilter;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.example.a99544.uidemo.R;
import com.example.a99544.uidemo.adapter.CityAdapter;
import com.example.a99544.uidemo.model.City;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends BaseActivity {

    private List<City> cityList=new ArrayList<City>();

    private RecyclerView mRecyclerView;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        TextView title=(TextView)findViewById(R.id.title) ;
        title.setText("选择地域");
        StaggeredGridLayoutManager layoutManager=new StaggeredGridLayoutManager(2,StaggeredGridLayoutManager.VERTICAL);//使用瀑布流布局
        mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
        mRecyclerView.setLayoutManager(layoutManager);
        initCitys();
        CityAdapter adapter = new CityAdapter(cityList);
        mRecyclerView.setAdapter(adapter);

    }

    private void initCitys() {


        //City beijing=new City("北京",R.drawable.beijing);
        //cityList.add(beijing);
        //City tianjin=new City("天津",R.drawable.tianjin);
        //cityList.add(tianjin);
        City hebei=new City("河北",R.drawable.qinhuangdao);
        cityList.add(hebei);
        City sichuan=new City("四川",R.drawable.sichuan);
        cityList.add(sichuan);
        City neimenggu=new City("内蒙古",R.drawable.hulunbeier);
        cityList.add(neimenggu);
        City liaoning=new City("辽宁",R.drawable.shenyang);
        cityList.add(liaoning);
        City jilin=new City("吉林",R.drawable.jilin);
        cityList.add(jilin);
        City haerbin=new City("哈尔滨",R.drawable.haerbin);
        cityList.add(haerbin);
        City chongqing=new City("重庆",R.drawable.chongqing);
        cityList.add(chongqing);
        City chengdu=new City("成都",R.drawable.chengdu);
        cityList.add(chengdu);
    }
}
